package com.tyg.controller;


import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.tyg.entity.TbVenueInfo;
import com.tyg.service.TbVenueInfoService;
import com.tyg.util.ResultCode;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author zhangjingnan
 * @since 2022-11-01
 */
@RestController
@RequestMapping("/tb-venue-info")
@CrossOrigin
@Slf4j
public class TbVenueInfoController {

    @Autowired
    TbVenueInfoService tbVenueInfoService;

    //模糊查询场地信息
    @PostMapping("/getVenueInfo")
    public ResultCode getVenueInfo(
            String venueName,
            Integer venueType,
            @RequestParam(defaultValue = "1" ,required = true)int pageIndex, Integer pageSize) {
        System.out.println("venueName:"+venueName);
        System.out.println("venueType:"+venueType);
        PageHelper.startPage(pageIndex, pageSize);
        Map<String,Object> map= new HashMap<>();
        map.put("venueName", venueName);
        map.put("venueType", venueType);
        List<TbVenueInfo> venueInfoList=tbVenueInfoService.getVenueInfo(map);
        PageInfo<TbVenueInfo> page= new PageInfo<TbVenueInfo>(venueInfoList);
        return ResultCode.success(page);
    }
}

